package com.lwj.liwanjia.presenter;

import com.lwj.liwanjia.bean.SuperMarketBean;
import com.lwj.liwanjia.impl.SuperMarkeView;
import com.lwj.liwanjia.model.SuperMarketModel;

import java.util.Map;

import rx.Subscriber;

/**
 * Created by Administrator on 2017/9/25.
 */

public class SuperMarketPresenter {
    private SuperMarkeView superMarkeView;
    private SuperMarketModel superMarketModel;

    public SuperMarketPresenter(SuperMarkeView superMarkeView) {
        this.superMarkeView = superMarkeView;
        superMarketModel = new SuperMarketModel();
    }

    public void getSuperMarketData(String type, double userLat, double userLng
            , String marketType, int page) {
        if (superMarkeView != null) {
            superMarketModel.getSuperMarketData(type, userLat, userLng, marketType, page, new Subscriber<SuperMarketBean>() {
                @Override
                public void onCompleted() {

                }

                @Override
                public void onError(Throwable e) {
                    superMarkeView.showError((Exception) e);
                }

                @Override
                public void onNext(SuperMarketBean superMarketBean) {
                    superMarkeView.getSuperMarketData(superMarketBean);
                }
            });
        }
    }
}
